﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WinApp.Model.EF_Model
{
    [Table("Exam")]
    public class Exam
    {
        public int Id { get; set; }

        public int? SAAS_ExaminationId { get; set; }

        public int? UserId { get; set; }

        public string? SurfacePlot { get; set; }
        public string? LastSAAS_TestPaperRoundName { get; set; }
        public int? LastSAAS_TestPaperRoundId { get; set; }
        public double? LastScore { get; set; }
        public string? SAAS_ExaminationName { get; set; }
        public int? LastStatu { get; set; }
        public long? BeginTime { get; set; }
        public long? EndTime { get; set; }
        public double? ExaminationDuration { get; set; }
        public int? SAAS_TestPaperId { get; set; }
        public int? LastSAAS_ExaminationRoundId { get; set; }
        public int? IsResume { get; set; }
        public int? ExamType { get; set; }
        public int? IsAppOfflineDownload { get; set; }

        public int? IsCache { get; set; }
        public string? ExaminationDescription { get; set; }

        [NotMapped]
        public DateTime? dtBeginTime
        {
            get
            {
                if (BeginTime.HasValue && BeginTime.Value != 0)
                {
                    DateTime resultDt;
                    resultDt = new DateTime(BeginTime.Value);
                    return resultDt;
                }
                else
                {
                    return null;
                }
            }
            set
            {
                if (value.HasValue)
                {
                    BeginTime = value.Value.Ticks;
                }
                dtBeginTime = value;
            }
        }

        [NotMapped]
        public DateTime? dtEndTime
        {
            get
            {
                if (EndTime.HasValue && EndTime.Value != 0)
                {
                    DateTime resultDt;
                    resultDt = new DateTime(EndTime.Value);
                    return resultDt;
                }
                else
                {
                    return null;
                }
            }
            set
            {
                if (value.HasValue)
                {
                    EndTime = value.Value.Ticks;
                }
                dtEndTime = value;
            }
        }
    }
}
